/*
 * LinkTypes.java
 *
 * Created on April 4, 2007, 6:21 PM
 *
 * This file is part of Five Points. See <http://www.fpdev.org> for
 * additional information regarding the project.
 * 
 * Five Points is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Five Points is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Five Points.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.fpdev.core.basenet;

/**
 *
 * @author demory
 */
public class LinkTypes {

  // major types
  public final static int MAJOR_TFARE = 1;
  public final static int MINOR_TFARE = 2;
  public final static int OTHER_STREET = 3;
  public final static int NONWALKABLE = 4;
  public final static int BIKE_PED = 5;
  public final static int TRANSIT = 6;
  public final static int RAIL = 7;
  // transit provisions -- applicable to thorroughfares only

  // thoroughfares
  public final static int MAJOR_TWOWAY = 10;
  public final static int MAJOR_ONEWAY = 11;
  public final static int MINOR_TWOWAY = 20;
  public final static int MINOR_ONEWAY = 21;

  // local street types
  public final static int LOCAL_TWOWAY = 30;
  public final static int LOCAL_ONEWAY = 31;
  
  // nonwalkable street types
  public final static int NW_GENERAL = 40;
  public final static int NW_EXPWY_GENERAL = 41;
  public final static int NW_EXPWY_MANAGED = 42;
  public final static int NW_SECONDARY_EXPWY = 43;
  public final static int NW_EXPWY_RAMP = 44;
  public final static int NW_SURFACE = 45;
  
  // bike/ped facility types
  public final static int BP_GENERAL = 50;
  
  // urban transit facility types
  public final static int TR_METRO = 60;
  public final static int TR_LRT = 61;
  public final static int TR_BUSWAY = 62;
  
  // heavy rail facility types
  public final static int RR_STANDARD = 70;
  
  // transit provision types
  public final static int TRPROV_BARRIER_SEPARATED_LRT = 1;
  public final static int TRPROV_BARRIER_SEPARATED_BUS_LANES = 2;
  public final static int TRPROV_INTEGRATED_LRT = 3;
  public final static int TRPROV_INTEGRATED_BUS_LANES = 4;

  // bike/ped provision types
  public final static int BPPROV_BARRIER_SEPARATED_MULTIUSE = 1;
  public final static int BPPROV_BARRIER_SEPARATED_BIKE = 2;
  public final static int BPPROV_STRIPED_LANES_FULL = 3;
  public final static int BPPROV_STRIPED_LANES_PARTIAL = 4;
  public final static int BPPROV_BIKEABLE_SHOULDER = 5;

  public static int linkTypetoClassType(int linkType) {
    int majorType = linkType / 10;
    if (majorType >= 1 && majorType <= 4) {
      return BLink.CLASS_STREET;
    }
    if (majorType == 5) {
      return BLink.CLASS_BIKEPED;
    }
    if (majorType == 6) {
      if (linkType == TR_METRO) {
        return BLink.CLASS_METRO;
      }
      if (linkType == TR_LRT) {
        return BLink.CLASS_LRT;
      }
    }
    if (majorType == 7) {
      return BLink.CLASS_RAILROAD;
    }
    return 0;
  }
}
